<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <link rel="stylesheet" href="/static/layui/css/layui.css">
</head>
<body>
<form id="plainForm" class="layui-form" method="post">
    <fieldset class="layui-elem-field">
        <legend>搜一搜</legend>
        <div class="layui-field-box">

        <#-- 企划名称块 -->
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">企划名称</label>
                    <div class="layui-input-block">
                        <input type="text" name="spName" placeholder="请输入企划名称"
                               autocomplete="off" class="layui-input" style="width: 189px;" value="${param.spName!''}">
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">促销条件</label>
                    <div class="layui-input-block">
                        <select name="conNo">
                            <option class="conNo" value="">请选择</option>
                        <#if saleList ? exists>
                            <#list saleList as sale>
                                <option class="conNo" value="${sale.con_no!''}">${sale.con_name!''}</option>
                            </#list>
                        </#if>
                        </select>
                    </div>
                </div>


                <div class="layui-inline">
                    <label class="layui-form-label">活动时间</label>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input name="startDate" placeholder="开始时间" autocomplete="off"
                               class="layui-input" onclick="layui.laydate({elem: this})"
                               type="text" value="${param.startDate!''}">
                    </div>
                    <div class="layui-form-mid">-</div>
                    <div class="layui-input-inline" style="width: 100px;">
                        <input name="endDate" placeholder="结束时间" autocomplete="off"
                               class="layui-input" onclick="layui.laydate({elem: this})"
                               type="text" value="${param.endDate!''}">
                    </div>
                </div>

            </div>


        <#-- 代金券块 -->
            <div class="layui-form-item">
                <div class="layui-inline">
                    <label class="layui-form-label">代金券</label>
                    <div class="layui-input-block">
                        <select name="cpnNo" id="cpnNo">
                            <option value="">请选择</option>
                        <#if cpnList ? exists >
                            <#list cpnList as cpn>
                                <option value="${cpn.cpnNo!''}">${cpn.cpnContent!''}</option>
                            </#list>
                        </#if>
                        </select>
                    </div>
                </div>

                <div class="layui-inline">
                    <label class="layui-form-label">企划可用</label>
                    <div class="layui-input-block">
                        <select name="isUsed" id="isUsed">
                            <option value="">请选择</option>
                            <option value="y">可用</option>
                            <option value="n">不可用</option>
                        </select>
                    </div>
                </div>

                <div class="layui-inline">
                    <div class="layui-input-block">
                        <button class="layui-btn" lay-submit lay-filter="formDemo">确定</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </div>

        </div>

    </fieldset>
    <fieldset class="layui-elem-field">
        <legend>看一看</legend>
        <div class="layui-field-box">
            <table class="layui-table">
                <colgroup>
                    <col width="150">
                    <col width="200">
                    <col width="200">
                    <col width="200">
                    <col width="200">
                    <col width="200">
                    <col width="200">
                    <col width="200">
                    <col width="200">
                    <col width="200">
                    <col width="200">
                    <col width="200">
                </colgroup>
                <thead>
                <tr>
                    <th>ID</th>
                    <th>企划编号</th>
                    <th>企划名称</th>
                    <th>促销条件</th>
                    <th>优惠</th>
                    <th>买赠</th>
                    <th>限额</th>
                    <th>开始时间</th>
                    <th>结束时间</th>
                    <th>企划可用</th>
                    <th>代金券</th>
                    <th>操作</th>
                </tr>
                </thead>
                <tbody>
                <#if list?exists>
                    <#list list as item>
                    <tr>
                        <td>${item.ID!''}</td>
                        <td>${item.spNo!''}</td>
                        <td>${item.spName!''}</td>
                        <td>${item.conName!''}</td>
                        <td>${item.disName!''}</td>
                        <td>${item.gName!''}</td>
                        <td>${item.lmtName!''}</td>
                        <td>${item.startDate!''}</td>
                        <td>${item.endDate!''}</td>
                        <td>
                            <#if item.isUsed?exists>
                                <#if item.isUsed == 'y'>
                                    可用
                                <#else >
                                    不可用
                                </#if>
                            <#else >
                            </#if>
                        </td>
                        <td>${item.cpnContent!''}</td>
                        <td>
                            <div val="${item.ID!''}" class="layui-btn layui-btn-radius manage">管理</div>
                        </td>
                    </tr>
                    </#list>
                </#if>


                </tbody>
            </table>
            <div class="layui-form">
                <span id="form_page"></span>&nbsp;共${page.total}条数据
            </div>
            <input type="hidden" id="currentPage" name="currentPage">
        </div>
    </fieldset>
</form>

<script type="text/javascript" src="/static/layui/layui.js"></script>
<script type="text/javascript">
    layui.use(['form', 'jquery', 'layer', 'laydate', 'laypage'], function () {
        var $ = layui.jquery;
        var form = layui.form();
        var layer = layui.layer;
        var laydate = layui.laydate;
        var laypage = layui.laypage;

        var pindex = "${page.pageNum}";// 当前页
        var ptotalpages = "${page.pages}";// 总页数
        var pcount = "${page.total}";// 数据总数

        //分页
        laypage({
            cont: 'form_page', // 页面上的id
            pages: ptotalpages,//总页数
            curr: pindex,//当前页。
            skip: true,
            jump: function (obj, first) {
                $("#currentPage").val(obj.curr);//设置当前页
                //防止无限刷新,
                //只有监听到的页面index 和当前页不一样是才出发分页查询
                if (obj.curr != pindex) {
                    $("#plainForm").submit();
                }
            }
        });



        $(".manage").on("click", function () {
            var thisVipId = $(this).attr("val");
            layer.open({
                title: '企划详情 - 企划管理'
                , area: ['500px', '400px']
                , type: 2
                , content: "/plain/findPlainInfoDetail?Id=" + thisVipId
            });
        });


        //监听提交
        form.on('submit(formDemo)', function (data) {
            return true;
        });


        var conNo = '${param.conNo!""}';
        var cpnNo = '${param.cpnNo!""}';
        var isUsed = '${param.isUsed!""}';

        if (conNo != '' && conNo != null) {
            $(".conNo[value=" + conNo + "]").attr("selected", true);
        }
        if (cpnNo != '' && cpnNo != null) {
            $("#cpnNo").find("option[value='" + cpnNo + "']").attr("selected", true);
        }
        if (isUsed != '' && isUsed != null) {
            $("#isUsed").find("option[value='" + isUsed + "']").attr("selected", true);
        }

        form.render();

    });
</script>
</body>
</html>